<template>
  <div id="total-online">
    <div id="total-online-title">
      <div class="total-online-title">
        <img src="static/img/yellow-con.png" class="total-online-img1">
        <img src="static/img/yellow-con.png" class="total-online-img2">
        <img src="static/img/yellow-con.png" class="total-online-img3">
        <img src="static/img/yellow-con.png" class="total-online-img4">
        <img src="static/img/yellow-con.png" class="total-online-img5">
        <img src="static/img/yellow-con.png" class="total-online-img6">
        <img src="static/img/yellow-con.png" class="total-online-img7">
        <img src="static/img/yellow-con.png" class="total-online-img8">
        <img src="static/img/blue-con.png" class="total-online-img9">
        <img src="static/img/blue-con.png" class="total-online-img10">
        <img src="static/img/blue-con.png" class="total-online-img11">
        <img src="static/img/blue-con.png" class="total-online-img12">
        <span>在线驾驶员数</span>
      </div>
    </div>
    <div id="total-online-num">
      {{allnum1}}
    </div>
  </div>
</template>

<script>
  export default {
    name: 'total-online',
    data() {
      return {
        allnum1: 234567890,
        timeList : 1513645200000
      }
    },
    mounted() {
      this.drawOnline();
      this.changeTimeList();
    },
    methods: {
      drawOnline: function () {
        let that = this;
        const total_sumdriver = [];
        $.ajax({
          type : 'get',
          async :true,
          url: 'http://203.81.245.37:2420/platformservice/right/' +that.timeList ,
          data : {},
          dataType: 'json',
          success : function (result) {
            if (result) {
              let total_sumdriver = result.sumdriver;
              // console.log(result.sumdriver);
              for (var i=0;i<total_sumdriver.length;i++) {
                total_sumdriver.push(total_sumdriver[i])
              }
//              console.log(99999999);
//              console.log(total_sumdistance);
//              console.log(typeof total_sumdistance)
              const _allsum = total_sumdriver.toString();
              const _allsum2 = _allsum.substr(2,3);
              const _allsum1 = _allsum.substr(0,2);
              const _allsum3 = _allsum1 + "," +_allsum2;
//              that.allnum1 = total_sumdriver;
              that.allnum1 = _allsum3;

            }
          }
        })
      },
      changeTimeList : function () {
        var timeList = [1514422800000,1514336400000,1514250000000,1514163600000,1514077200000,1513990800000,1513904400000,1513818000000,1513731600000,1513645200000];
        var j = 0;
        setInterval( () => {
          this.timeList = timeList[j];
//          console.log(timeList[j]);
          if (j < timeList.length-1){
            j+=1;
          }else {
            j = 0;
          }
          this.drawOnline();
        },60000)
      }
    }
  }
</script>

<style>
  #total-online {
    height: 100px;
    width: 440px;
    position: relative;
  }
  #total-online-title {
    height: 40px;
    width: 438px;
    background: rgba(7, 34, 31, 0.8);
    border-width: 1px;
    border-style: solid;
    border-color: rgba(32, 221, 201, 0.8);
    border-image: initial;
  }
  .total-online-title {
    height: 30px;
    width: 428px;
    position: absolute;
    top: 6px;
    left: 6px;
    font-family: MicrosoftYaHeiUI;
    text-align: left;
    text-indent: 4px;
    font-size: 18px;
    line-height: 30px;
    color: rgb(239, 187, 66);
    letter-spacing: -0.45px;
    background: rgba(0, 158, 158, 0.2);
  }
  #total-online-num {
    height: 57px;
    width: 438px;
    background: rgba(7,34,31,0.80);
    border: 1px solid rgba(32,221,201,0.80);
    position: absolute;
    top: 40px;
    /*left: 1px;*/
    font-family: MicrosoftYaHeiUI-Bold;
    font-size: 48px;
    color: #FFFFFF;
    letter-spacing: 10px;
    line-height: 58px;
    text-align:center;
  }
  .total-online-img1 {
    position: absolute;
    top: -7px;
    left: -7px;
    z-index: 3;
  }
  .total-online-img2 {
    position: absolute;
    top: -7px;
    left: 429px;
    transform: rotate(90deg);
    z-index: 3;
  }
  .total-online-img3 {
    position: absolute;
    top: 30px;
    left: 429px;
    transform: rotate(180deg);
    z-index: 3;
  }
  .total-online-img4 {
    position: absolute;
    top: 30px;
    left: -7px;
    transform: rotate(270deg);
    z-index: 3;
  }
  .total-online-img5 {
    position: absolute;
    top: 33px;
    left: -7px;
    z-index: 3;
  }
  .total-online-img6 {
    position: absolute;
    top: 33px;
    left: 429px;
    transform: rotate(90deg);
    z-index: 3;
  }
  .total-online-img7 {
    position: absolute;
    top: 88px;
    left: 429px;
    transform: rotate(180deg);
    z-index: 3;
  }
  .total-online-img8 {
    position: absolute;
    top: 88px;
    left: -7px;
    transform: rotate(270deg);
    z-index: 3;
  }
  .total-online-img9 {
    position: absolute;
    top: -1px;
    left: -1px;
    z-index: 3;
  }
  .total-online-img10 {
    position: absolute;
    top: -1px;
    left: 425px;
    transform: rotate(90deg);
    z-index: 3;
  }
  .total-online-img11 {
    position: absolute;
    top: 27px;
    left: 425px;
    transform: rotate(180deg);
    z-index: 3;
  }
  .total-online-img12 {
    position: absolute;
    top: 27px;
    left: -1px;
    transform: rotate(270deg);
    z-index: 3;
  }
</style>
